@echo off
REM 编译Solidity合约脚本 (Windows)

echo Compiling ERC20Token.sol...

REM 检查solc是否安装
where solc >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
    echo Error: solc (Solidity compiler) is not installed.
    echo Please install it using: npm install -g solc
    exit /b 1
)

REM 创建输出目录
if not exist "build\contracts" mkdir build\contracts
if not exist "src\main\resources\contracts" mkdir src\main\resources\contracts

REM 编译合约
solc --bin --abi src\main\resources\contracts\ERC20Token.sol -o build\contracts\

REM 检查编译是否成功
if exist "build\contracts\ERC20Token.bin" (
    echo Contract compiled successfully!
    echo Copying bytecode to resources...
    copy build\contracts\ERC20Token.bin src\main\resources\contracts\ >nul
    echo Done! Contract bytecode is now available at src\main\resources\contracts\ERC20Token.bin
) else (
    echo Error: Compilation failed. Please check the Solidity contract.
    exit /b 1
)

